#include <bits/stdc++.h>
using namespace std;
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
using ll = long long;
void solve()
{
    ll n,ans=0,mx=0;
    cin >> n;
    vector<ll> a(n + 1),pre(n+1,0);
    for (ll i = 0; i < n;i++)
    {
        cin >> a[i];
        if(mx>a[i])
        {
            ans = max(ans, mx + a[i]);
        }
        mx = max(a[i], ans);
    }
    cout << ans << endl;
}
int main()
{
    int t = 1;
    cin >> t;
    while(t--)
    {
        solve();
    }
   return 0;
}
